package zoo.member.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import zoo.member.domain.MemberCommand;



public class MemberJoinValidator implements Validator {

	
	public boolean supports(Class<?> clazz) {
		
		return MemberCommand.class.isAssignableFrom(clazz); 
	}
	
	public void validate(Object target, Errors errors) {
		MemberCommand command = (MemberCommand) target;
		System.out.println(command);
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userid", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "upwd", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uname","required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uphone", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uaddr", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uresaddr", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uzipcode", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uemail", "required");

		
		
	}
}
